/*
 * @Author : Genustin
 * @Date   : 2012-06-26
 * 求肿瘤面积和周长，边缘不规则
 */
#include <iostream>
using namespace std;
#ifndef N
#define N 100
#endif

int main()
{
	int psize;
	int pixes[N*N];
	int area, inner;
	area  = 0;
	inner = 0;
	cin >> psize;
	for(size_t i = 0; i < psize*psize; ++i) 
	{
		cin >> pixes[i];
	}
	for(size_t i = 0; i < psize*psize; ++i)
	{
		if(pixes[i] <= 50) 
		{
			++area; //计算总面积
			if( i-psize >= 0 and pixes[i-psize] <= 50 //非第一行
				and i+psize < psize*psize and pixes[i+psize] <= 50 //非最后行
				and (i-1)%psize != psize-1 and pixes[i-1] <= 50 //非最左列
				and (i+1)%psize != 0 and pixes[i+1] <= 50) //非最右列
			{
				++inner; //计算内部点
			}		
		}

	}
	cout << area << ' ' << area-inner << endl;	
	return 0;
}
